package com.company.service;


import com.company.dao.UserDAO;
import com.company.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminService {
    @Autowired
    private UserDAO userDAO;

    public User login(String name, String pwd) {
        User u = userDAO.getByName(name);
        if (u != null && u.getPwd().equals(pwd)) {
            return u;
        } else {
            return null;
        }
    }
    public int reg(String name, String pwd) {
        User temp = userDAO.getByName(name);
        if (temp != null){
            return -2;
        }
        User u = new User();
        u.setName(name);
        u.setPwd(pwd);
        return userDAO.add(u);
    }

}
